

function saveStyleOn() {
	$("#save").mouseover(function() {
		$("#save").css("background-color", "rgb(242,88,7)");
		$("#save").css("transition", "0.5s");
	});
}

function saveStyleOut() {
	$("#save").mouseout(function() {
		$("#save").css("background-color", "rgb(225,103,9)");
		$("#save").css("transition", "0.5s");
	});
}

function cancelStyleOn() {
	$("#cancel").mouseover(function() {
		$("#cancel").css("background-color", "rgb(117,117,117)");
		$("#cancel").css("transition", "0.5s");
	});
}

function cancelStyleOut() {
	$("#cancel").mouseout(function() {
		$("#cancel").css("background-color", "rgb(176,176,176)");
		$("#cancel").css("transition", "0.5s");
	});
}


function onMyAddressStyle(){
	$("#myAddress").css("border", "1px solid rgb(176,176,176)");
	$("#mybtn").show();
}

function outMyAddressStyle(){
	$("#myAddress").css("border", "1px solid rgb(224,224,224)");
	$("#mybtn").hide();
}
function namestyleFo() {

	$("#name").css("border", "1px solid rgb(225,103,9)");
	$("#name").attr("placeholder", "收货人姓名");

}

function namestyleBl() {

	$("#name").css("border", "1px solid rgb(176,176,176)");
	$("#name").attr("placeholder", "姓名");

}

function phonestyleFo() {

	$("#phone").css("border", "1px solid rgb(225,103,9)");
	$("#phone").attr("placeholder", "11位手机号");

}

function phonestyleBl() {

	$("#phone").css("border", "1px solid rgb(176,176,176)");
	$("#phone").attr("placeholder", "手机号");

}

function adrsstyleFo() {

	$("#adrs").css("border", "1px solid rgb(225,103,9)");
	$("#adrs").attr("placeholder", "详细地址，路名，街道，门牌号");

}

function adrsstyleBl() {

	$("#adrs").css("border", "1px solid rgb(176,176,176)");
	$("#adrs").attr("placeholder", "详细地址");

}

function sendmunstyleFo() {

	$("#sendmun").css("border", "1px solid rgb(225,103,9)");
	$("#sendmun").attr("placeholder", "");

}

function sendmunstyleBl() {

	$("#sendmun").css("border", "1px solid rgb(176,176,176)");
	$("#sendmun").attr("placeholder", "邮政编号");

}

function signstyleFo() {

	$("#sign").css("border", "1px solid rgb(225,103,9)");
	$("#sign").attr("placeholder", "如'家'，'公司'");

}

function signstyleBl() {

	$("#sign").css("border", "1px solid rgb(176,176,176)");
	$("#sign").attr("placeholder", "地址标签");

}

function showAddress(e) {
	$("#selectList").each(function() {
		var proJson;
		var cityJson;
		var xianJson;
		var temp_html;
		var oProvince = $(this).find("#province");
		var oCity = $(this).find("#city");
		var oDistrict = $(this).find("#district");

		var province = function() {
			temp_html = "<option value='s' selected>省份/自治区</option>";
			$.each(proJson.province, function(i, province) {
				temp_html += "<option value='" + province.ProID + "'>" + province.name + "</option>";
			});
			oProvince.html(temp_html);
			city();
		};

		var city = function() {
			temp_html = "<option value='c' selected>城市/地区</option>";
			var proid = oProvince.get(0).value;
			for(var i = 0; i < cityJson.city.length; i++) {
				var city = cityJson.city[i];
				if(proid == city.ProID) {
					temp_html += "<option value='" + city.CitySort + "'>" + city.name + "</option>";
				}
			}
			oCity.html(temp_html);
			district();
		};

		var district = function() {
			temp_html = "<option value='x' selected>区/县</option>";
			var cityId = oCity.get(0).value;
			for(var i = 0; i < xianJson.xian.length; i++) {
				var xian = xianJson.xian[i];
				if(cityId == xian.CityID) {
					temp_html += "<option value='" + xian.Id + "'>" + xian.DisName + "</option>";
				}
			}
			oDistrict.html(temp_html);
		};

		//选择省改变市
		oProvince.change(function() {
			city();
		});
		//选择市改变县
		oCity.change(function() {
			district();
		});

		//获取json数据
		$.getJSON("json/provice.json", function(data) {
			proJson = data;
			province();
		});
		$.getJSON("json/city.json", function(data) {
			cityJson = data;
			city();
		});
		$.getJSON("json/xian.json", function(data) {
			xianJson = data;
			district();
		});
	});
	    layui.use('layer',function() {
			var layer = layui.layer;
		    layer.open({
			type: 1,
			title:'添加地址',
			area: ['355px', '575px'],
			maxmin: false,
			shadeClose: true,
			content: $('#pms'),
		    yes: hideAddress
		});
		});

}

function hideAddress() {
	layer.closeAll();
}

function saveAddress() {
	alert("123");
	var name = $("#name").val;
	alert(name);
	if(name.length == 0) {
		$("#name").val("请输入你的名字");
	}
	var phone = $("#phone").value;
	var test = /((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/;
	if(phone.length == 0) {
		$("#phone").val("请输入你的电话号码");
	} else if(!test.test(phone)) {
		$("#phone").val("电话号码错误");
	}

}